home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / infosrvr / dev / libhtml_.tar / debug.h < prev    next >
C/C++ Source or Header  |  1993-01-20  |  1KB  |  54 lines

  1. /* debug.h -- Connolly's debugging junk
  2.  * $Id: debug.h,v 1.4 92/09/10 22:04:24 connolly Exp $
  3.  * Copyright 1992 by Convex Computer Corporation, Richardson, Texas.
  4.  * See the COPYRIGHT file for details.
  5.  *
  6.  * USE: debug(("debugging message", printf, args))
  7.  * just like you would printf, but with extra ().
  8.  * They turn to a null expression statement ((void)0) at
  9.  * compile time if DEBUG is not true.
  10.  */
  11.  
  12. #define DEBUG_DEFAULT 0
  13.  
  14. #ifndef DEBUG
  15. #define DEBUG DEBUG_DEFAULT
  16. #endif
  17.  
  18. #if DEBUG
  19. #  include <stdio.h>
  20. #  define debug(x) printf x
  21. #  define Debug(s, x) ((debug_##s) ?  printf x : 0)
  22. #else
  23. #  define debug(x) do{}while(0)
  24. #  define Debug(s, x) do{}while(0)
  25. #endif
  26.  
  27. /*
  28.  * REQUIRE(condition, stmnt_if_fail)
  29.  * be sure to free dynamic memory on failure.
  30.  * e.g.
  31.  * p = malloc(size);
  32.  * REQUIRE(x>0, return (free(p), -1));
  33.  */
  34. #define REQUIRE(x,return_y)                   \
  35.   if(!(x)){                                   \
  36.     debug(("requirement failed: %s\n", #x));  \
  37.     return_y;                                 \
  38.   }
  39.  
  40. #define TIMING_DEFAULT 0
  41.  
  42. #ifndef TIMING
  43. #define TIMING TIMING_DEFAULT
  44. #endif
  45.  
  46. #if TIMING
  47. extern "C" clock(void);
  48. #define timing(s) printf("<%s>clock = %d\n", s, clock())
  49. #else
  50. #define timing(s) do{}while(0)
  51. #endif
  52.  
  53.  
  54.